

# from selenium import webdriver
# from selenium.webdriver.common.by import By



# from selenium.webdriver.support.ui import WebDriverWait    #显性时间
# from selenium.webdriver.support import expected_conditions as EC  #显性时间


#
# @allure.story("初始化前提")
# @pytest.fixture(scope="function", autouse=True,name="a")
# def setup():
#     with allure.step("实例化chrome驱动"):
#         driver = webdriver.Chrome()
#     with allure.step("打开网址"):
#         driver.get("http://jxc.b2zg.cn/#/login")
#     with allure.step("最大化"):
#         driver.maximize_window()
#     with allure.step("隐式等待"):
#         driver.implicitly_wait(10)
#
#     with allure.step("点击登录"):
#         WebDriverWait(driver, 10, 0.5).until(EC.presence_of_element_located((By.XPATH, "//*[text()='体验一下']"))).click()    #登录
#         time.sleep(1)
#     with allure.step("登录断言"):
#         a1 = driver.find_elements(By.CLASS_NAME, "clearfix")[0].text  # 快速菜单
#         assert a1 == "快速菜单"
#
#
#     yield driver
#     driver.quit()















import time
import pytest
import allure
import requests

base_url="http://120.55.83.187:8899"


@allure.story("夹具：登录")
@pytest.fixture(scope="function")
def login():
    a=requests.post(url=base_url+"/adminapi/login",json={"account":"admin","pwd":"A123456!"})
    assert a.status_code == 200
    token=a.json()["data"]["token"]
    yield token


@allure.story("夹具：查询用户分组")
@pytest.fixture(scope="function")
def check_group(login):
    a=requests.get(url=base_url+"/adminapi/user/user_group/list?page=1&limit=15",headers={'Authori-zation':'Bearer '+str(login)})
    assert a.status_code == 200
    b=a.json()
    b1=b['data']['list'][-1]['id']   #b=30
    yield b1

<<<<<<< HEAD
def setup():
    driver = webdriver.Chrome()
    driver.get("http://jxc.b2zg.cn/#/login")
    driver.maximize_window()
    driver.implicitly_wait(10)
=======


@allure.story("夹具：查询客服话术")
@pytest.fixture(scope="function")
def check_speech(login):
    time.sleep(3)
    a=requests.get(url=base_url+"/adminapi/app/wechat/speechcraft?page=1&limit=15&cate_id=",headers={'Authori-zation':'Bearer '+str(login)})
    assert a.status_code == 200
    b=a.json()
    b2=b['data']['list'][-1]['id']
    yield b2
>>>>>>> d42229fdb7e32c0e1591a81b4fb8535a0618a194


@allure.story("夹具：查询用户标签")
@pytest.fixture(scope="function")
def check_label(login):
    time.sleep(3)
    a=requests.get(url=base_url+"/adminapi/user/user_label?page=1&limit=15&label_cate=",headers={'Authori-zation':'Bearer '+str(login)})
    assert a.status_code == 200
    b=a.json()
    b3=b['data']['list'][-1]['id']
    yield b3













base_url2="http://jxc.b2zg.cn"


@allure.story("快捷登录")
@pytest.fixture(scope="function")
def login2():
    a=requests.post(url=base_url2+"/api/public/userExperience/loginOnPc")
    assert a.status_code == 200
    token=a.json()["data"]["access_token"]
    yield token



@allure.story("搜索商品分类，查pid级")
@pytest.fixture(scope="function")
def check_classification1(login2):
    a=requests.post(url=base_url2+"/api/goodCat/listAllData",headers={'authorization':'Bearer '+str(login2)})
    time.sleep(1)
    b=a.json()

    b1=b["data"][-1]["pid"]    #pid指该级
    yield b1


@allure.story("搜索商品分类，查id具体删除")
@pytest.fixture(scope="function")
def check_classification2(login2):
    a=requests.post(url=base_url2+"/api/goodCat/listAllData",headers={'authorization':'Bearer '+str(login2)})
    time.sleep(1)
    b=a.json()
    b2=b["data"][-1]["id"]
    yield b2






